<script setup lang="ts" name="SystemMailAccountDetail">
import { DICT_TYPE } from '@/enums/dictEnums'
import { MailAccountApi, MailAccountType } from '@/api/system/messages/mail/account'

const { t } = useI18n() // 国际化
const visible = ref(false) // 弹窗的是否展示
const detailLoading = ref(false) // 表单的加载中
const detailData = ref({} as MailAccountType) // 详情数据

/** 打开弹窗 */
const open = async (id: number) => {
  visible.value = true
  // 设置数据
  try {
    detailData.value = await MailAccountApi.detail(id)
  } finally {
    detailLoading.value = false
  }
}
defineExpose({ open }) // 提供 open 方法，用于打开弹窗
</script>

<template>
  <Dialog v-model="visible" :title="t('sys.messages.mail.account', 'detail')" type="scroll" height="500px" width="800px">
    <el-descriptions :column="1" border>
      <el-descriptions-item :label="t('sys.messages.mail.account', 'mail')">
        {{ detailData.mail }}
      </el-descriptions-item>
      <el-descriptions-item :label="t('sys.messages.mail.account', 'username')">
        {{ detailData.username }}
      </el-descriptions-item>
      <el-descriptions-item :label="t('sys.messages.mail.account', 'password')">
        {{ detailData.password }}
      </el-descriptions-item>
      <el-descriptions-item :label="t('sys.messages.mail.account', 'host')">
        {{ detailData.host }}
      </el-descriptions-item>
      <el-descriptions-item :label="t('sys.messages.mail.account', 'port')">
        {{ detailData.port }}
      </el-descriptions-item>
      <el-descriptions-item :label="t('sys.messages.mail.account', 'sslEnable')" min-width="120">
        <dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="detailData.sslEnable + ''" />
      </el-descriptions-item>
    </el-descriptions>
  </Dialog>
</template>

<style scoped lang="scss"></style>
